function serDlg() {
    $("#searchDlg").modal();
    document.getElementById("search_input").value="";
}


var $search=$("#search_button");
function validateSearchId() {
    return $("#select").validate({
        rules: {
            search_input: {
                digits: true
            }
        },
        messages: {
            search_input: {
                digits: "id必须是整数！"
            }
        }
    });
}
$search.click(function () {
    var value = $("#search_select ").val();//获取select的值
    // alert(value);
        if(value==="rpId") {
            if(validateSearchId().form()) {
                searchrpId();
                // console.log("1111")
            }
    } else if(value==="rpName"){
        searchrpName();
    } else if(value==="rpRequir"){
        searchrpRequir();
    } else if(value==="rpConclu"){
        searchrpConclu();
    } else if(value==="rpRelationship"){
        searchrpRelationship();
    }
    else if(value==="rpConditions"){
        searchrpConditions();
    }
});

function searchrpId() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据

            url: "/pattern/find/rpId",
            datatype: 'json',
            mtype: "post",
            postData: {"rpId": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }

}

function searchrpName() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/pattern/find/rpName",
            datatype: 'json',
            mtype: "post",
            postData: {"rpName": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}

function searchrpRequir() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/pattern/find/rpRequir",
            datatype: 'json',
            mtype: "post",
            postData: {"rpRequir": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}

function searchrpConclu() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/pattern/find/rpConclu",
            datatype: 'json',
            mtype: "post",
            postData: {"rpConclu": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}

function searchrpRelationship() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/pattern/find/rpRelationship",
            datatype: 'json',
            mtype: "post",
            postData: {"rpRelationship": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}

function searchrpConditions() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/pattern/find/rpConditions",
            datatype: 'json',
            mtype: "post",
            postData: {"rpConditions": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}